package org.dairy.farms.model;

import org.dairy.farms.interceptor.hibernate.AuditInterceptor;
import org.dairy.farms.interceptor.hibernate.Auditable;

import javax.persistence.*;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 * Created by IntelliJ IDEA.
 * User: gduggirala
 * Date: Jun 8, 2011
 * Time: 9:29:43 PM
 */
@Table(name = "CHECKUP")
//@EntityListeners({AuditInterceptor.class})
@Entity
public class Checkup implements Auditable {

    @javax.persistence.Column(name = "ID")
    @Id
    @GeneratedValue
    private Long id;

    @OneToMany(mappedBy = "checkup", targetEntity = Disease.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Set<Disease> forDiseases = new HashSet<Disease>();

    @OneToMany(mappedBy = "checkup", targetEntity = Vaccine.class, fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    private Set<Vaccine> vaccines = new HashSet<Vaccine>();

    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinColumn(name = "PERSON_ID")
    private Person doctor;

    @OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY)
    @JoinColumn(name = "EXPENSE_ID")
    private CheckUpExpense checkUpExpense;

    @javax.persistence.Column(name = "DATE")
    private Date dateOfCheckup;

    @ManyToOne
    @JoinColumn(name = "LIVESTOCK_ID")
    private Livestock livestock;

/*
    @javax.persistence.Column(name = "EXPENSE")
    private Double expense;
*/

    @ManyToOne
    @JoinColumn(name = "CHECKUP_TYPE_ID")
    private CheckupType checkupType;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    /*public MedicalRecord getMedicalRecord() {
        return medicalRecord;
    }

    public void setMedicalRecord(MedicalRecord medicalRecord) {
        this.medicalRecord = medicalRecord;
    }*/

    public Set<Disease> getForDiseases() {
        return forDiseases;
    }

    public void setForDiseases(Set<Disease> forDiseases) {
        this.forDiseases = forDiseases;
    }

    public Set<Vaccine> getVaccines() {
        return vaccines;
    }

    public void setVaccines(Set<Vaccine> vaccines) {
        this.vaccines = vaccines;
    }

    public Person getDoctor() {
        return doctor;
    }

    public void setDoctor(Person doctor) {
        this.doctor = doctor;
    }

    public Date getDateOfCheckup() {
        return dateOfCheckup;
    }

    public void setDateOfCheckup(Date dateOfCheckup) {
        this.dateOfCheckup = dateOfCheckup;
    }

    public Livestock getLivestock() {
        return livestock;
    }

    public void setLivestock(Livestock livestock) {
        this.livestock = livestock;
    }

    public CheckUpExpense getCheckUpExpense() {
        return checkUpExpense;
    }

    public void setCheckUpExpense(CheckUpExpense checkUpExpense) {
        this.checkUpExpense = checkUpExpense;
    }

    public CheckupType getCheckupType() {
        return checkupType;
    }

    public void setCheckupType(CheckupType checkupType) {
        this.checkupType = checkupType;
    }

    @Embedded
    private AuditInfo auditInfo = new AuditInfo();

    public AuditInfo getAuditInfo() {
        return auditInfo;
    }

    public void setAuditInfo(AuditInfo auditInfo) {
        this.auditInfo = auditInfo;
    }
}
